home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / mint / editors / mjovesrc.zoo / teachjov.c < prev    next >
C/C++ Source or Header  |  1992-04-04  |  1KB  |  53 lines

  1. /***************************************************************************
  2.  * This program is Copyright (C) 1986, 1987, 1988 by Jonathan Payne.  JOVE *
  3.  * is provided to you without charge, and with no warranty.  You may give  *
  4.  * away copies of JOVE, including sources, provided that this notice is    *
  5.  * included in all the files.                                              *
  6.  ***************************************************************************/
  7.  
  8. #include <stdio.h>
  9. #include <sys/types.h>
  10. #include <sys/file.h>
  11.  
  12. #ifndef    TEACHJOVE
  13. #    define TEACHJOVE    "/usr/lib/jove/teach-jove"
  14. #endif
  15.  
  16. #ifndef    W_OK
  17. #   define W_OK    2
  18. #   define F_OK    0
  19. #endif
  20.  
  21. #ifdef    __STDC__
  22. #define    proto(x)    x
  23. #else
  24. #define    proto(x)    ()
  25. #endif
  26.  
  27. extern char    *getenv proto((const char *));
  28. extern int    access proto((const char *, int));
  29. extern int    system proto((const char *));
  30. extern int    execlp proto((const char *, const char *, ...));
  31.  
  32. int
  33. main()
  34. {
  35.     char    cmd[256],
  36.         fname[256],
  37.         *home;
  38.  
  39.     if ((home = getenv("HOME")) == NULL) {
  40.         printf("teachjove: cannot find your home!\n");
  41.         exit(-1);
  42.     }
  43.     (void) sprintf(fname, "%s/teach-jove", home);
  44.     if (access(fname, F_OK) != 0) {
  45.         (void) sprintf(cmd, "cp %s %s; chmod 644 %s", TEACHJOVE, fname, fname);
  46.         system(cmd);
  47.     }
  48.     (void) execlp("jove", "teachjove", fname, (char *) NULL);
  49.     printf("teachjove: cannot execl jove!\n");
  50.     return 1;
  51. }
  52.  
  53.